package com.itheima.exception;


import org.springframework.stereotype.Component;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@Component
@ControllerAdvice
public class ProjectExceptionAdvice {

    @ExceptionHandler(BusinessException.class)
    public String doBusinessException(Exception e, Model m){
        m.addAttribute("msg",e.getMessage());
        return "error.jsp";
    }


    @ExceptionHandler(SystemException.class)
    public String doSystemException(Exception e, Model m){
        m.addAttribute("msg","服务器出现问题，请联系管理员");
        return "error.jsp";
    }

    @ExceptionHandler(Exception.class)
    public String doException(Exception e,Model m){
        m.addAttribute("msg",e.getMessage());
        return "error.jsp";
    }
}
